//$(".my-message").css({"border-bottom":"solid 4px #097c25","height":"60px","display":"inline-block"});
var shoujihm = $('#shoujihm').text().trim();//用户原手机号码
//点击更换手机号码
var yanZhengMa;
$(".g-change-number").click(function(){
	$(".isHide").toggle();
	if(yanZhengMa&&$("#yuanmima").val()==""&&$("#xinmima").val()==''&&$("#querenmm").val()==""){
		$("#btnSubmit").removeAttr("disabled");
		yanZhengMa = false;
	}
	$("#xinshoujihm").val("");
	$("#yanzhengma").val("");
});

//点击获取验证码
$('#g-verification-code').click(function(){
	$(this).removeClass("input-border");
	yanZhengMa = true
	var newShoujihm =$('#xinshoujihm').val();
	var validateResult = validateShoujihmgs(newShoujihm);// 校验手机号码格式
	if (validateResult!='true') {
		notifyWarning(validateResult);
		return false;
	} else {
		var kehuxx = getKehuxxByShoujihm(newShoujihm);// 获取到客户信息
		if (kehuxx != '' && kehuxx.zhuangtai != 4) {// 改客户存在并且状态为激活状态
			notifyWarning('该手机号码已存在');
			$('.yanzhengma-msg').html("");
			$("#btnSubmit").attr("disabled", true);
			return false;
		} else {
			$("#btnSubmit").removeAttr("disabled");
			if (kehuxx.zhuangtai == 4) {
				$('#hizhuangtai').val(4);
			}
			settime($('#g-verification-code'));
			yanzhengmfs(newShoujihm)// 发送短信
			notifySuccess("验证码已发送成功,请注意查收~");
		}
	}
	
});

//当提交按钮被点击
$('#btnSubmit').click(function(event){
	var yuanmimayz = true;
	var newShoujihm = $('#xinshoujihm').val();//获取到新手机号码的值
	var xinnima	= $('#xinmima').val();//获取新密码
	var yuanmm =$("#yuanmima").val();//获取原密码
	var querenmm = $("#querenmm").val();//获取确认密码
	var isHide = $('.isHide').css("display");//获取隐藏信息display;
	if(newShoujihm=="") {//如果其值为空，说明没有更改号码
		//把hidden表单的值设置为原手机号码的值
		$('#hiddenShoujihm').attr('value',shoujihm);
		$('#isNew').attr('value','false');
	}else{//如果值不为空，说明更改了手机号码
		var validateResult = validateShoujihmgs(newShoujihm);// 校验手机号码格式
		if (validateResult!='true') {
			notifyWarning(validateResult);
			$("#btnSubmit").attr("disabled", true);
			return false;
		} else {
			var kehuxx = getKehuxxByShoujihm(newShoujihm);// 获取到客户信息
			if (kehuxx != '' && kehuxx.zhuangtai != 4) {// 改客户存在并且状态为激活状态
				notifyWarning('该手机号码已存在');
				$('.yanzhengma-msg').html("");
				$("#btnSubmit").attr("disabled", true);
				return false;
			} 
		}
		//把hidden表单的值设置为更改之后的手机号码的值
		$('#hiddenShoujihm').attr('value',newShoujihm);
		$('#isNew').attr('value','true');
	}
	$.ajax({
		url:path+'/yonghu/validataMima',
		type:'POST',
		async:false,
		data:{mima:yuanmm},
		success:function(data) {
			if(yuanmm == '') {//原密码未输入
			}else if(data=="success") {
			}else{
				notifyWarning('原密码不正确');
				yuanmimayz = false;
			}
		}
	}); 
	if(yuanmm!=""&&xinnima == querenmm){
	}else if(yuanmm==""&&xinnima == querenmm){
		if(xinnima!=""){
			notifyWarning('请填写完整密码信息');
			return false;
		}
	}
	
		$('#yourForm').validator({
			fields: {
				'xingming': '姓名: required;length(1~64)',
				'xingbie': 'checked',
				'password': '密码:password;',
				'mima':'match(password);'
			},
			valid: function(form){
				if(yuanmimayz){
					//执行提交
					$.ajax({
						url:path+'/yonghu/zhanghaoxx',
						type:'POST',
						async:false,
						data:$('#yourForm').serialize(),
						success:function(data) {
							if(data=='success') {
								var msg = "账号信息已更新";
								msg = encodeURI(encodeURI(msg));
								var sjc = new Date().getTime();
								window.location.href=path+'/jump/toZhanghaoxx?msg='+msg+'&sjc='+sjc;
							}else{
								notifyWarning(data);
							}
						}
					});
				}
			}
		});
	
	
});
//当原密码input光标离开
$('#yuanmima').blur(function() {
	var yuanmima =$("#yuanmima").val();
	$.ajax({
		url:path+'/yonghu/validataMima',
		type:'POST',
		data:{mima:yuanmima},
		success:function(data) {
			if(yuanmima == '') {//原密码未输入
			}else if(data=="success") {
			}else{
				notifyWarning('原密码不正确');
				yuanmimayz = false;
			}
		}
	}); 
});
//点击性别时radio属性跟着lable属性变化
$(".g-radio-shield label:not(.g-label-name)").on("click",function(){
	$(this).addClass("on").siblings().removeClass("on");
});
//form校验配置
$('form').validator({
	stopOnError:"true",
	ignore: ':hidden',
	fields: {
		'email': 'required;email;'
	}
});